package com.wzcl.app.model.vo;

import com.wzcl.app.dao.model.SendPath;
import com.wzcl.app.model.common.WZCL;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@EqualsAndHashCode(callSuper = false)
@Data
public class SendPathVo extends BaseVo {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用户Id")
    private String userId;

    @ApiModelProperty(value = "用户手机")
    private String userPhone;

    @ApiModelProperty(value = "详细地址")
    private List<String> path;

    @ApiModelProperty(value = "详细地址")
    private String pathInfo;

    @ApiModelProperty(value = "收货人姓名")
    private String name;

    @ApiModelProperty(value = "收货人手机号")
    private String phone;

    @ApiModelProperty(value = "状态")
    private Integer state;
    private String stateStr;

    @ApiModelProperty(value = "是否为默认地址")
    private Boolean isDefault;
    private String isDefaultStr;

    private SendPathVo(){
    }

    public static SendPathVo create(SendPath sendPath){
        SendPathVo sendPathVo = new SendPathVo();
        BeanUtils.copyProperties(sendPath,sendPathVo);
        sendPathVo.path = Arrays.asList(sendPath.getPath().split(","));
        sendPathVo.translationValueStr();
        return sendPathVo;
    }

    @Override
    public void translationValueStr() {
        Map<String, Map<Integer, String>> map = getTranslationMap();
        this.stateStr=map.get(WZCL.GROUP_NAME.STATE).get(this.state);
        this.isDefaultStr=this.isDefault?"默认地址":"";
    }

    @Override
    public void processResources() {

    }
}
